<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 商品图片
 * 
 * @author  : $Author: spike $
 * @date    : $Date: 2014-02-25 13:43:37 +0800 (二, 2014-02-25) $
 * @version : $Id: goods_img.php 31 2014-02-25 05:43:37Z spike $
 * @rev     : $Revision: 31 $
 */
class Goods_img extends CI_Controller 
{  
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * [首页]
     */
    public function index()
    {
        $this->load->model('Goods_model');
        $data = array(
            'max_upload_item' => Goods_model::$MAX_UPLOAD_ITEM,
        );
        $this->load->view('home/header.tpl', $data);
        $this->load->view('goods_img/index.tpl');
        $this->load->view('home/footer.tpl');
    }

    /**
     * [上传]
     */
    public function upload()
    {
        $config = array(
            'upload_path'   => TEMP_PATH,
            'allowed_types' => 'zip',
            'encrypt_name'  => TRUE,
            'overwrite'     => FALSE,
        );
  
        $this->load->library('upload', $config);
 
        if ( ! $this->upload->do_upload('goods_img'))
        {
            show_error($this->upload->display_errors());
        }
        $upload = $this->upload->data();

        $this->load->model('Goods_model');
        if( FALSE === $result = $this->Goods_model->gen_goods_img($upload['full_path']) )
        {
            show_error($this->Goods_model->get_error());
        }

        $data = array(
            'result'  => $result,
            'max_img' => Goods_model::$MAX_IMG,
        );

        $this->load->view('home/header.tpl', $data);
        $this->load->view('goods_img/result.tpl');
        $this->load->view('home/footer.tpl');
    }
}
/* End of file */